home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-09 | 8.9 KB | 279 lines | [TEXT/KEEN] |
- #$Lockout: WARNING LOOKOUT OH GOSH
- #This program can only be terminated with
- #<Command><period> when it is set for message display. If you forget that, you’ll
- #have to do something considerably more drastic to get it to stop.
-
- #Usage: none that’s defendable.
- #Probably the worst example program provided.
-
- #There are two basic modes of operation, determined by the
- #value of “use_marquee”. This variable ca be set with the
- #“Set variables” dialog -- if
- # use_marquee=0
- #then a long plain-text message can be displayed; if
- # use_marquee=1
- #then giant capitals will be used for the display.
- #The giant messages for the marquee take around 5 minutes
- #to generate, so you have the option of saving messages to
- #a file and reading it back in. Set
- # write_message=1
- #and the generated giant message will be written to disk, in
- #a file with the same name as the message, in your “hAWK programs”
- #folder. Set
- # read_message=1
- #and the message will be read from disk, rather than regenerated.
- #In both cases the message and file name is determined by the
- #line just after the comment #MARQUEE MESSAGE below.
-
- #Modes of behaviour:
- #use_marquee=0 ;endless loop, displays the message after “#long text message”
- #use_marquee=1 ;
- # if write_message=1 and read_message=0 , writes the giant MARQUEE MESSAGE and exits
- # (this may take 5 or so minutes)
- # if read_message=1 , reads the giant message from the file named by MARQUEE MESSAGE
- # and write_message is ignored ; loops endlessly
- # if write_message=1 and read_message=0 , generates and displays the MARQUEE MESSAGE
- # and loops endlessly (takes about five minutes to get going)
- #Written and restored giant messages should be no more than 31 characters in length,
- #and composed of uppercase, numbers, and !.,-? only.
- #Change the text message to your liking. If a long message with use_marquee=0
- #folds to the second line, reduce fieldWidth a bit to compensate.
-
- #Oddity note - your screen-saver may still work
- #even while hAWK is running.
-
- # User’s Manual references:
- # «hAWK User’s Manual» «F Running hAWK programs»
- # «hAWK User’s Manual» «L 5 Regular expressions»
- # «hAWK User’s Manual» «M 5 Built-in string and file functions»
- # «hAWK User’s Manual» «K 4 Built-in variables»
- # «hAWK User’s Manual» «K 8 Arrays»
- # «hAWK User’s Manual» «N User-defined functions»
- # «hAWK User’s Manual» «P 3 The getline function»
- # «hAWK User’s Manual» «O 3 Output into files»
- # «hAWK User’s Manual» «Q The hAWK function»
-
-
- BEGIN { fieldWidth = 45 #number of text characters in plain message at once
- marqueeWidth = 7 #number of giant marquee characters at once
- if (use_marquee+0 == 0)
- {
- #long text message
- message = "Extremely sophisticated algorithm under test -- please do not touch."
- ScrollMessage(message);
- }
- else
- {
- #MARQUEE MESSAGE
- #Canned messages: "OUT TO LUNCH", "PLEASE DO NOT TOUCH!!"
- message = "PLEASE DO NOT TOUCH!!";#use uppercase, numbers, and ?!.,- only
- if (read_message+0 != 0)
- {
- msgfile = STDPATH "Drag_on Modules:hAWK programs:" message
- while (getline < msgfile > 0)
- {
- s[++z] = $0
- for (q = 1; q <= 4; ++q)
- {
- if (getline < msgfile > 0)
- s[z] = s[z] "\n" $0
- }
- }
- close(msgfile)
- $0 = ""
- }
- ScrollMarqueeMessage();
- }
- }
-
- function ScrollMessage(msg, m,i, totalLen, three_m, shifter)
- {
- m = length(msg)
- for (i = 1; i < fieldWidth; ++i)
- field_blanks = field_blanks " "
- three_m = 3*m
- for (i = 1; i <= three_m; ++i)
- three_m_blanks = three_m_blanks " "
- msg = three_m_blanks field_blanks msg
- totalLen = m + fieldWidth + three_m
- while (1)
- {
- shifter = int(rand()*m) + 1
- for (i = 1 + (three_m - 3*shifter); i <= totalLen; ++i)
- {
- progress_string = substr(msg, i+ 3*shifter, fieldWidth)\
- "\n" substr(msg, i+ 2*shifter, fieldWidth)\
- "\n" substr(msg, i+shifter, fieldWidth)\
- "\n" substr(msg, i, fieldWidth);
- progress(progress_string)
- wait()
- }
- wait()
- progress(time())
- for (i = 1; i <= 50; ++i)
- wait()
- }
- }
-
- function wait( i)
- {
- for (i = 1; i <= 20; ++i)
- ;
- }
-
- function ScrollMarqueeMessage( m,i,totalLen,totalStrings)
- {
- if (read_message+0 == 0 || z+0 == 0)
- {
- InitMarquee();
- m = length(message)
- if (m == 0)
- {
- message = "BYE FOR NOW"
- m = length(message)
- }
- for (i = 1; i <= marqueeWidth; ++i)
- field_blanks = field_blanks " "
- if (write_message+0 != 0)
- msgfile = STDPATH "Drag_on Modules:hAWK programs:" message
- message = field_blanks message
- totalLen = m + marqueeWidth
- for (i = 1; i <= totalLen; ++i)
- {
- textStr = substr(message, i, marqueeWidth+1)
- for (bitOff = 0; bitOff < 5; ++bitOff)
- {
- StringToMarquee()
- PrintMarqueeToString(5*(i-1)+bitOff+1)
- #progress(marquee_string)
- }
- }
- totalStrings = 5*totalLen
- if (write_message+0 != 0)
- {
- for (i = 1; i <= totalStrings; ++i)
- print s[i] > msgfile
- exit #optional
- }
- }
- else
- totalStrings = z;
- while (1)
- {
- for (i = 1; i <= totalStrings; ++i)
- {
- progress(s[i])
- wait()
- }
- wait()
- progress(time())
- for (i = 1; i <= 20; ++i)
- wait()
- }
- }
-
-
- function StringToMarquee( char, i, len)
- {
- InitMarqueeArray()
- len = length(textStr)
- if (len > marqueeWidth+1)
- len = marqueeWidth+1;
- for (i = 1; i <= len; ++i)
- {
- char = substr(textStr, i, 1)
- SetMarqueeLetter(i, char)
- }
- }
-
- function InitMarqueeArray( i,j, true_length)
- {
- true_length = (marqueeWidth+1)*5
- for (i = -5; i <= true_length; ++i)
- {
- for (j = 1; j <= 5; ++j)
- arr[j,i] = " ";#<Option><space>
- }
- }
-
- #arr is 2-D array holding row,column (1 up) of the entire displayed
- #message; each giant character is 5 by 5 real Chicago characters
- #with the darker characters defined by the marquee array below.
- #charPos is position of marquee letter (1 up)
- #bitOffset is offset of character in characters (0-4) to the LEFT (-ve interpretation
- #of its positive value)
- #char is the marquee character.
- #The digit 1 is used as the printing character - this can be changed
- #to anything else that’s the same size
- function SetMarqueeLetter(charPos, char, offset, n, i)
- {
- if (char == " " || char == "\t")
- return;
- n = split(marquee[char], coords);
- offset = 5*(charPos-1) - bitOff
- for (i = 1; i < n; i += 2)
- arr[coords[i], coords[i+1]+offset] = "1";
- }
-
- function PrintMarqueeToString(ind, i,j, true_length)
- {
- s[ind] = ""
- true_length = marqueeWidth*5
- for (j = 1; j <= 5; ++j)
- {
- for (i = 1; i <= true_length; ++i)
- {
- s[ind] = s[ind] arr[j,i]
- }
- if (j < 5)
- s[ind] = s[ind] "\n"
- }
- }
-
- #MarqueeFont: pairs of row/column coordinates, each 1:5
- #This took forever to do - never again.
- function InitMarquee()
- {
- marquee["A"] = "1 3 2 2 2 4 3 1 3 2 3 3 3 4 3 5 4 1 4 5 5 1 5 5"
- marquee["B"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 2 3 3 3 4 4 1 4 5 5 1 5 2 5 3 5 4"
- marquee["C"] = "1 2 1 3 1 4 2 1 3 1 4 1 5 2 5 3 5 4"
- marquee["D"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 5 4 1 4 5 5 1 5 2 5 3 5 4"
- marquee["E"] = "1 1 1 2 1 3 1 4 1 5 2 1 3 1 3 2 3 3 3 4 4 1 5 1 5 2 5 3 5 4 5 5"
- marquee["F"] = "1 1 1 2 1 3 1 4 1 5 2 1 3 1 3 2 4 1 5 1"
- marquee["G"] = "1 2 1 3 1 4 1 5 2 1 3 1 3 4 4 5 4 1 4 5 5 2 5 3 5 4 5 5"
- marquee["H"] = "1 1 1 5 2 1 2 5 3 1 3 2 3 3 3 4 3 5 4 1 4 5 5 1 5 5"
- marquee["I"] = "1 2 1 3 1 4 2 3 3 3 4 3 5 2 5 3 5 4"
- marquee["J"] = "1 1 1 2 1 3 1 4 1 5 2 3 3 1 3 3 4 1 4 3 5 2"
- marquee["K"] = "1 1 1 4 2 1 2 3 3 1 3 2 3 3 4 1 4 4 5 1 5 5"
- marquee["L"] = "1 1 2 1 3 1 4 1 5 1 5 2 5 3 5 4"
- marquee["M"] = "1 1 1 5 2 1 2 2 2 4 2 5 3 1 3 3 3 5 4 1 4 5 5 1 5 5"
- marquee["N"] = "1 1 1 5 2 1 2 2 2 5 3 1 3 3 3 5 4 1 4 4 5 5 5 1 5 5"
- marquee["O"] = "1 2 1 3 1 4 2 1 2 5 3 1 3 5 4 1 4 5 5 2 5 3 5 4"
- marquee["P"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 2 3 3 3 4 4 1 5 1"
- marquee["Q"] = "1 2 1 3 1 4 2 1 2 5 3 1 3 5 4 1 4 3 3 5 5 2 5 3 5 4"
- marquee["R"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 2 3 3 3 4 4 1 4 4 5 1 5 5"
- marquee["S"] = "1 2 1 3 1 4 2 1 3 2 3 3 3 4 4 5 5 1 5 2 5 3 5 4"
- marquee["T"] = "1 1 1 2 1 3 1 4 1 5 2 3 3 3 4 3 5 3"
- marquee["U"] = "1 1 1 5 2 1 2 5 3 1 3 5 4 1 4 5 5 2 5 3 5 4"
- marquee["V"] = "1 1 1 5 2 1 2 4 3 1 3 3 4 1 4 2 5 1"
- marquee["W"] = "1 1 1 5 2 1 2 5 3 1 3 3 3 5 4 1 4 2 4 4 4 5 5 1 5 5"
- marquee["X"] = "1 1 1 5 2 2 2 4 3 3 4 2 4 4 5 1 5 5"
- marquee["Y"] = "1 1 1 5 2 2 2 4 3 3 4 3 5 3"
- marquee["Z"] = "1 1 1 2 1 3 1 4 1 5 2 4 3 3 4 2 5 1 5 2 5 3 5 4 5 5"
- marquee["0"] = "1 3 1 4 2 2 2 5 3 2 3 5 4 2 4 5 5 2 5 3"
- marquee["1"] = "1 3 2 2 2 3 3 3 4 3 5 2 5 3 5 4"
- marquee["2"] = "1 2 1 3 1 4 2 5 3 3 3 4 4 2 4 5 5 2 5 3 5 4 5 5"
- marquee["3"] = "1 2 1 3 1 4 2 5 3 3 3 4 4 5 5 2 5 3 5 4"
- marquee["4"] = "1 2 1 4 2 2 2 4 3 2 3 3 3 4 3 5 4 4 5 4"
- marquee["5"] = "1 2 1 3 1 4 1 5 2 2 3 2 3 3 3 4 4 5 5 2 5 3 5 4"
- marquee["6"] = "1 4 1 5 2 3 3 2 3 4 3 5 4 3 4 5 5 4 5 5"
- marquee["7"] = "1 2 1 3 1 4 1 5 2 4 3 3 4 2 5 2"
- marquee["8"] = "1 3 1 4 2 2 2 5 3 3 3 4 4 2 4 5 5 2 5 3"
- marquee["9"] = "1 3 1 4 2 2 2 5 3 3 3 4 3 5 4 5 5 4 5 5"
- marquee["."] = "4 2 4 3 5 2 5 3"
- marquee["?"] = "1 1 1 2 1 3 2 4 3 2 3 3 5 2"
- marquee["!"] = "1 2 1 3 2 2 2 3 3 2 3 3 5 2 5 3"
- marquee[","] = "3 2 3 3 4 3 5 2"
- marquee["-"] = "3 2 3 3 3 4"
- }
-